<template>
  <div>
    <div>click</div>
  </div>
</template>
<script>
// import websocket from 'src/assets/js/webSocket'
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'websocket',
  // mixins: [websocket],
  computed: {
    ...mapGetters([
      'stompClient'
    ])
  },
  methods: {
    onConnect () {
      console.log('连接成功')
      this.onSubscribe()
    },
    onSubscribe () {
      // this.stompClient.send('/test', {}, 'ceshi')
      this.client = this.stompClient.subscribe('/topic/getResponse', this.onmessage)
    },
    onmessage (res) {
      console.log('消息', res)
    },
    ...mapActions([
      'getWebScoket'
    ])
  },
  created () {
    // this.getWebScoket(this.onConnect)
  },
  destroyed () {
    this.client.unsubscribe()
  }
}
</script>
